home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
ELECTRON
/
PCB_DESI
/
1540.ZIP
/
PCBCA110.ZIP
/
ALLOC.C
next >
Wrap
C/C++ Source or Header
|
1990-11-18
|
697b
|
31 lines
#include <stdio.h>
#include <stdlib.h>
#ifdef VMS
#define far
#else
#include <dos.h>
#endif
char far *Alloc( long );
void Nomem( void );
char far *Alloc ( x ) /* allocate x bytes of far memory */
long x;
{
union REGS regs;
regs.h.ah = 0x48; /* allocate memory dos call */
x = (x+15)>>4; /* get number of paragraphs to allocate */
regs.x.bx = (int)x;
intdos( ®s, ®s ); /* call dos; request memory */
if (regs.x.cflag) /* memory allocation error */
Nomem();
return( (char far *)((long)regs.x.ax<<16) ); /* make a far pointer */
}
void Nomem () { /* a memory allocation request has failed */
fprintf( stderr, "out of memory\n" );
exit( -1 );
}